package com.wfw.second.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.wfw.common.pojo.TestVo;
import com.wfw.second.service.SentinelService;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @ Author     ：duanchao
 * @ Date       ： 13:25 2021/1/8
 * @ Description：
 */

@Service
public class SentinelServiceImpl implements SentinelService {

    @SentinelResource(value = "ser-uuid" ,blockHandler = "blockHandlerTest")
    @Override
    public String getUUid() {
        return UUID.randomUUID().toString();
    }



    // Block 异常处理函数，参数最后多一个 BlockException，其余与原函数一致.
    public static String blockHandlerTest(BlockException ex) {
        // Do some log here.
        System.out.println("***************************** 进入异常·");

        ex.printStackTrace();
        return "Oops, error occurred at " ;
    }

}